package com.itheima.springbootwebbtalis.mapper;

import com.github.pagehelper.Page;
import com.itheima.springbootwebbtalis.pojo.Student;
import com.itheima.springbootwebbtalis.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {

    Page<Student> selectByPage(StudentQueryParam param);

   @Insert("insert into student (id, name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id, violation_count, violation_score, create_time, update_time) values (null,#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},0,0,#{createTime},#{updateTime});")
    void add(Student student);

   @Select("select * from student where id = #{id};")
    Student showById(Integer id);

    void update(Student student);


    void deleteById(List<Integer> ids);

    void violation(Integer id, short score);

    List<Map> clazzCount();

    List<Map> degreeCount();
     @Select("select count(*) from student where clazz_id=#{id};")
    Integer deleteByClazzId(Integer id);
}
